import type { JobForm, JobQuery, JobVO } from './model';

import type { ID, IDS, PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
 * 查询定时任务调度列表
 * @param params
 * @returns 定时任务调度列表
 */
export function jobList(params?: JobQuery) {
  return requestClient.get<PageResult<JobVO>>('/monitor/job/list', { params });
}

/**
 * 导出定时任务调度列表
 * @param params
 * @returns 定时任务调度列表
 */
export function jobExport(params?: JobQuery) {
  return commonExport('/monitor/job/export', params ?? {});
}

/**
 * 查询定时任务调度详情
 * @param jobId id
 * @returns 定时任务调度详情
 */
export function jobInfo(jobId: ID) {
  return requestClient.get<JobVO>(`/monitor/job/${jobId}`);
}

/**
 * 新增定时任务调度
 * @param data
 * @returns void
 */
export function jobAdd(data: JobForm) {
  return requestClient.postWithMsg<void>('/monitor/job', data);
}

/**
 * 更新定时任务调度
 * @param data
 * @returns void
 */
export function jobUpdate(data: JobForm) {
  return requestClient.putWithMsg<void>('/monitor/job', data);
}

/**
 * 删除定时任务调度
 * @param jobId id
 * @returns void
 */
export function jobRemove(jobId: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/monitor/job/${jobId}`);
}

/**
 *  任务详细
 * @param jobId id
 * @returns void
 */
export function monitorJob(jobId: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/monitor/job/${jobId}`);
}
